package com.jastar.android.jigsaw;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public class HomeActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        super.findViewById(R.id.button_1).setOnClickListener(this);
        super.findViewById(R.id.button_2).setOnClickListener(this);
        super.findViewById(R.id.button_3).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (R.id.button_1 == v.getId()) {
            jumpActivity(MainActivity.class, 0);
        } else if (R.id.button_2 == v.getId()) {
            jumpActivity(MainActivity.class, 1);
        } else if (R.id.button_3 == v.getId()) {
            jumpActivity(MainActivity.class, 2);
        }
    }

    private void jumpActivity(Class<?> cls, int level) {
        Intent intent = new Intent(this, cls);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra(MainActivity.SIGN_LEVEL, level);
        super.startActivity(intent);
    }

}